#pragma once

#ifndef FTIPS_HANDORIENTATION_H_
#define FTIPS_HANDORIENTATION_H_

#include "cv.h"
#include <list>
#include <map>

struct CvPoint;
struct CvSeq;
struct CvBox2D;

namespace ftips {
	class PointsClassifier;

	class HandOrientation
	{
		//private methods
	private:
		static CvPoint GetFingerDirection(CvPoint *p, CvPoint *pBeforeK, CvPoint *pAfterK);
		static bool GetMainDirection(std::list<CvPoint> *pFingerVecsList, std::list<CvPoint> *pFingerTipsList, CvPoint *pDirection);
		static void RoughEraseVecs(std::list<CvPoint> *pFingerVecsList, std::list<CvPoint> *pFingerTipsList, CvPoint *pDirection);
		static void CalcTipsWeight(std::list<CvPoint> *pFingerTipsList, CvPoint *pDirection, double weight[]);
		static double CalcWeightThreshold(CvPoint *pOrigin, CvBox2D *pBox, CvPoint *pDirection);	
		static int GetDeletePos(double weight[], int size, double threshold);
		static void DoFilter(std::list<CvPoint> *pFingerTipsList, int sort[], int deletePos);
		static void FiltTipsByDirectionWeight(std::list<CvPoint> *pFingerTipsList, CvPoint *pDirection, CvBox2D *pBox);

		// public methods
	public:
		HandOrientation(void);
		~HandOrientation(void);

		static CvPoint GetOrientationAndFiltTips(CvSeq *pContour, PointsClassifier *pClassifier, std::list<CvPoint> *pFingerTipsList, int interval);
	};

}

#endif
